package com.jdb.banner.provider.entity;

import com.guns21.common.util.DateUtils;
import com.guns21.support.entity.AbstractEntity;
import com.jdb.banner.api.BannerCategory;
import lombok.Data;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
import java.util.Date;

@Data
@Entity
@Table(name="TB_BANNER")
public class BannerDO extends AbstractEntity {
    /**
     * 标题
     */
    private String title;
    /**
     * 发布时间
     */
    private Date publishTime;
    /**
     * 封面图url
     */
    private String cover;
    /**
     * 简介
     */
    private String summary;

    /**
     * 分类
     */
    @Enumerated(EnumType.STRING)
    @Column(length = 36)
    private BannerCategory category;
    /**
     * 元数据,必须是对象 {}
     */
    @Column(columnDefinition = "json")
    private String meta;

    @Override
    public void prePersist() {
        super.prePersist();
        setPublishTime(DateUtils.newDate());
    }
}
